﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using WmsApp.WindowControl;

namespace WmsApp.WmsService
{
    public partial class PayApplyBill : IWcfState
    {
        public static PayApplyBill CreatePayApplyBill(string inBillID)
        {
            var r = new PayApplyBill
            {
                PayApplyBillID = inBillID,
                PayApplyState = Constant.BillStateDraft,
                PayApplyDate = DateTime.Now.Date,
                TotalAmount = 0,
                InBillID = inBillID,
                PayApplyDept = "采购部",
                PayState = Constant.PayNotAffirm,
                WcfEntityState = System.Data.EntityState.Added
            };
            //InStoreBill inBill = Factory.WmsServiceFactory.GetServiceClient().GetInStoreBillWrap(inBillID).PInStoreBill;
            //r.ProviderCode = inBill.ProviderCode;
            //r.ProviderName = inBill.ProviderName;

            //Customer customer = Factory.WmsServiceFactory.GetServiceClient().GetCustomer(r.ProviderCode);
            //if(customer != null)
            //{
            //    r.BankAccount = customer.OWNERACCOUNT;
            //    r.OpeningBank = customer.OWNERBANK;
            //}

            r.BindPropertyChanged();
            return r;
        }

        public void BindPropertyChanged()
        {
            this.PropertyChanged += WmsApp.EntityControl.PropertyChangedHandler.EntityObjectPropertyChanged;
        }

        public string PayApplyStateDesc
        {
            get
            {
                if (PayApplyState == Constant.BillStateDraft)
                    return "草稿";
                else if (PayApplyState == Constant.BillStateAffirm)
                    return "确认";
                else if (PayApplyState == Constant.BillStateDelete)
                    return "作废";
                return "未知";
            }
        }
    }
}
